from django.db.models.signals import pre_save
from django.dispatch import receiver
from .models import User

@receiver(pre_save, sender=User)
def deduct_membertime(sender, instance, **kwargs):
    if instance.membertime > 0:
        instance.membertime -= 1
    else:
        instance.membertime = 0